package common;

import java.io.Serializable;

/**
 * This class represents a command message that is used for delivering
 * commands from client to server and back
 *
 */
public class CommandMessage extends AbstractMessage implements Serializable{
	

	/** 
	 * 
	 */
	private static final long serialVersionUID = 8163591408029211962L;
	public static final String ACKNOWLEDGE_MESSAGE = "ACK";
	public static final String LOGIN_MESSAGE = "LGN";
	public static final String LOGOUT_USER = "LGO";
	public static final String CREATE_USER = "CRU";
	public static final String GET_QUESTIONS = "GQU";
	public static final String DELETE_QUESTION = "QDE";
	public static final String GET_COURSES = "GCR";
	public static final String GET_SUBJECTS = "GSB";
	public static final String ADD_QUESTION = "ADQ";
	public static final String EDIT_QUESTION = "EDQ";
	public static final String GET_QUESTION = "GEQ";
	public static final String GET_EXAMS = "GES";
	public static final String GET_EXAMS_BY_SUBJECT_COURSE = "GSC";
	public static final String DELETE_EXAM = "DEX";
	public static final String ADD_EXAM = "ADE";
	public static final String EDIT_EXAM = "EDE";
	public static final String REMOVE_QUESTION_FROM_EXAM = "REQ";
	public static final String ADD_QUESTION_TO_EXAM = "AEQ";
	public static final String GET_EXAM_NOT_EXISTENT_QUESTIONS = "NEQ";
	public static final String ADD_EXAM_EXECUTION = "AEE";
	public static final String START_EXAM_EXECUTION = "SEE";
	public static final String GET_EXAMS_CODE_WHICH_TIME_CHANGED= "GEC";
	public static final String GET_NOTES_BY_CODE= "GNC";
	public static final String GET_ADDITIONAL_TIME_BY_CODE = "GAC";
	public static final String ACCEPT_OR_REJECT_ADDITIONAL_TIME = "ART";
	public static final String REQUEST_ADDITIONAL_TIME = "RAT";
	public static final String LOCK_EXAM_EXECUTION = "LEE";
	public static final String GET_STUDENT_EXAM = "GCE";
	public static final String SUBMIT_STUDENT_EXAM = "SSE";
	public static final String CHECK_EXISTENCE_OF_EXAM_EXECUTION_CODE = "CEC";
	public static final String GET_STUDENTS_WHICH_GRADE_NOT_APPROVED = "GSG";
	public static final String GET_STATUS_OF_EXAM_EXECUTION = "GSE";
	public static final String GET_TEACHER_REPORT = "GTR";
	public static final String GET_EXECUTED_STUDENT_EXAMS = "ESE";
	public static final String CONFIRM_STUDENT_GRADE = "CSG";
	public static final String GET_EXAM_EXECUTIONS = "GEE";
	public static final String GET_STUDENTS_WHICH_GRADE_IS_APPROVED = "GSA";
	public static final String GET_STUDENT_GRADE = "GSD";
	public static final String GET_EXAM_EXECUTION_REPORT = "GER";
	public static final String VERIFY_EXAM_INFO = "VEI";
	public static final String GET_AUTO_EXAM_ID_LIST = "GAI";
	public static final String GET_COURSE_NAME = "GCN";
	public static final String GET_STATISTICS_REPORT = "GSR";
	public static final String GET_TEACHERS = "GTH";
	public static final String GET_STUDENTS = "GST";

	
	
	private String command;
	private Object[] params;
	
	/**
	 * Default constructor
	 */
	public CommandMessage() {
		command = "";
		params = null;
	}
	
	/**
	 * Constructor
	 * @param command Command string
	 * @param params Command parameters as objects array
	 */
	public CommandMessage(String command, Object[] params) {
		this.command = command;
		this.params = params;
	}
	
	/**
	 * Command getter
	 * @return Command
	 */
	public String getCommand() {
		return command;
	}
	
	/**
	 * Command setter
	 * @param command Command to set
	 */
	public void setCommand(String command) {
		this.command = command;
	}

	/**
	 * Command parameters getter
	 * @return Command parameters array
	 */
	public Object[] getParams() {
		return params;
	}
	
	/**
	 * Command parameters setter
	 * @param params Command parameters array
	 */
	public void setParams(Object[] params) {
		this.params = params;
	}
	
	/**
	 * Represent message as debug string
	 */
	@Override
	public String ToDebugMessage() {
		String ret = "Command: " + command;
		if (params != null && params.length > 0) {
			ret += " Parameters: ";
			for(Object o:params) {
				ret += o.toString() + ", ";
			}
		}
		return ret ;
	}

}
